// 传感器类型
export enum SensorType {
  FLEX = 'flex',         // 弯曲传感器
  IMU = 'imu',           // 惯性测量单元(MPU6050)
  HEART_RATE = 'heart_rate', // 心率传感器
  PRESSURE = 'pressure', // 压力传感器
  TEMPERATURE = 'temperature', // 温度传感器
}

// 设备状态
export enum DeviceStatus {
  ONLINE = 'online',
  OFFLINE = 'offline',
  LOW_BATTERY = 'low_battery',
  ERROR = 'error',
}

// 患者设备类型
export enum PatientDeviceType {
  WEARABLE = 'wearable',     // 可穿戴设备
  EXOSKELETON = 'exoskeleton', // 外骨骼设备
  BRACE = 'brace',          // 康复支具
  MONITOR = 'monitor',      // 监护设备
}

// 传感器数据接口
export interface SensorData {
  type: SensorType;
  value: number | number[];
  timestamp: number;
  unit: string;
  isNormal: boolean;
  threshold?: {
    min: number;
    max: number;
  };
}

// 患者设备接口
export interface PatientDevice {
  deviceId: string;
  name: string;
  type: PatientDeviceType;
  status: DeviceStatus;
  lastConnected: number;
  batteryLevel: number;
  firmwareVersion: string;
  sensors: SensorType[];
  location?: string;
  isActive: boolean;
}

// 设备数据上报接口
export interface DeviceDataReport {
  deviceId: string;
  patientId: string;
  timestamp: number;
  sensorData: SensorData[];
  deviceStatus: DeviceStatus;
  batteryLevel: number;
  signalStrength?: number;
}

// 康复训练数据
export interface RehabilitationData {
  sessionId: string;
  patientId: string;
  startTime: number;
  endTime: number;
  deviceId: string;
  exercises: {
    name: string;
    duration: number;
    repetitions: number;
    rangeOfMotion?: {
      min: number;
      max: number;
      average: number;
    };
    accuracy?: number;
  }[];
  completionRate: number;
  feedback?: string;
}

// 实时监控数据
export interface RealTimeMonitoringData {
  patientId: string;
  deviceId: string;
  timestamp: number;
  vitalSigns: {
    heartRate?: number;
    bloodPressure?: {
      systolic: number;
      diastolic: number;
    };
    temperature?: number;
  };
  movementData?: {
    acceleration: number[];
    gyroscope: number[];
    orientation: number[];
    rangeOfMotion?: number;
  };
  alerts?: {
    type: string;
    message: string;
    severity: 'low' | 'medium' | 'high';
  }[];
}

// 设备配置接口
export interface DeviceConfig {
  deviceId: string;
  samplingRate: number; // 采样率 Hz
  batteryThreshold: number; // 电池阈值 %
  alertThresholds: {
    [sensorType in SensorType]?: {
      min: number;
      max: number;
      enabled: boolean;
    };
  };
  dataUploadInterval: number; // 数据上传间隔 ms
  autoReportEnabled: boolean;
}